<!--hmc 创建用户旅程第一步：设置规则-->
<template>
  <div class="page-container page-container-detail-page">
    <!--面包屑导航-->
    <div class="breadcrumb">
      <el-breadcrumb separator-class="el-icon-arrow-right">
        <el-breadcrumb-item>自动化营销</el-breadcrumb-item>
        <el-breadcrumb-item>用户旅程管理</el-breadcrumb-item>
        <el-breadcrumb-item>创建用户旅程</el-breadcrumb-item>
      </el-breadcrumb>
    </div>
    <div class="pageName">创建用户旅程</div>
    <!-- 当前页面进度条 -->
    <div class="stepset stepset3">
      <ul>
        <li :class="{'active':active>=1}">
          <span>1</span>
          <p>设置旅程规则</p>
        </li>
        <li :class="{'active':active>=2}">
          <span>2</span>
          <p>设计流程</p>
        </li>
        <li :class="{'active':active>=3}">
          <span>3</span>
          <p>创建成功</p>
        </li>
      </ul>
    </div>

    <!-- 流程示意title部分 -->
    <div class="flow-sketch">
      <span class="dot"></span>
      <span class="title">流程示意</span>
    </div>


    <div class="page-container-detail"> 
    <!-- 页面主体部分 -->
    <div class="main-content">
      <panel :journeyId="journeyId" :isEdit="isEdit" :timeType="timeType"></panel>
    </div>
    </div>
  </div>
</template>
<script>
// 自动化营销----------创建用户旅程第二步：设置流程
import panel from '@/components/AutoMarket/setPath/panel';
export default {
  name: "stepTwo",
  components: {
    panel
  },
  computed: {
    mainTabs: {
      get() {
        return this.$store.state.tab.mainTabs;
      },
      set(val) {
        this.$store.commit("updateMainTabs", val);
      }
    },
    mainTabsActiveName: {
      get() {
        return this.$store.state.tab.mainTabsActiveName;
      },
      set(val) {
        this.$store.commit("updateMainTabsActiveName", val);
      }
    }
  },
  data() {
    return {
      active: 2,                    // 当前步骤高亮值
      journeyId: "",                // 当前旅程ID
      isEdit: false,                // 是否为编辑
      timeType: 1,                  // 第一步创建旅程时设置的事件类型， 1-----固定时间段   2----无固定时间（提交保存的时候需要弹窗提示）
    };
  },

  methods: {

    // 点击取消返回用户旅程列表
    back() {
      this.$router.go(-1)
    },

    // tabs, 删除tab
    removeTabHandle(tabName) {
      this.mainTabs = this.mainTabs.filter(item => item.name !== tabName);
      if (this.mainTabs.length >= 1) {
        // 当前选中tab被删除
        if (tabName === this.mainTabsActiveName) {
          let tab = this.mainTabs[this.mainTabs.length - 1];
          this.$router.push(
            { path: tab.path,params: tab.params, query: tab.query},
            () => {
              this.mainTabsActiveName = this.$route.name;
            }
          );
        }
      } else {
        this.$router.push("/");
      }
    },
    
  },

  created() {
    // 获取第一步创建旅程带来的ID
    this.journeyId = this.$route.query.id;
    this.timeType = this.$route.query.timeType;

    // 如果是编辑页面跳转过来，请求详情借口进行数据的回显
    if(this.$route.query.isEdit == 1) {
      this.isEdit = true;
    }
    this.removeTabHandle("创建用户旅程")
  }
};
</script>
<style lang="scss" scoped>
@import '../../../../assets/css/public.scss';
.breadcrumb {
  background-color: #fff;
  height: 14px;
  line-height: 14px;
  margin-bottom: 0 !important;
}
.pageName{
  color: #333;
  font-size: 20px;
  margin-bottom: 0;
  text-align: center;
  margin-right: 150px;
  margin-top:30px;
}
.stepset {
  margin-bottom: 30px;
}
.stepset.stepset3 ul {
  margin: 20px auto 0;
}
.page-container{
  padding: 40px 20px 40px 40px;
  background-color: #fff;
}
.page-container-detail{
  padding: 0;
  background: none;
  box-shadow: none;
  .main-content{
    margin-top: 0;
  }
}

/* 流程示意图部分样式 */
.flow-sketch {
  text-align: left;
  margin-bottom: 10px;
  .dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #25a4e4;
  }
  .title {
    display: inline-block;
    color: #333;
    font-size: 14px;
    margin-left: 5px;
  }
} 
</style>

